package com.cwd.arm.infrastructure.dao.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.cwd.arm.common.util.SessionUtil;
import com.cwd.arm.infrastructure.dao.MsgDao;
import com.cwd.arm.infrastructure.dao.base.DaoImpl;
import com.cwd.arm.infrastructure.mapper.MsgMapper;
import com.cwd.arm.infrastructure.po.MsgPo;
import com.cwd.arm.infrastructure.query.MsgDaoQuery;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* Description:消息
* Created on 2022年01月15日
* @author  yan
*/
@Service
public class MsgDaoImpl extends DaoImpl<MsgMapper, MsgPo> implements MsgDao {

    @Override
    public List<MsgPo> selectByQuery(MsgDaoQuery msgDaoQuery) {
        QueryWrapper<MsgPo> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq(ObjectUtils.isNotEmpty(msgDaoQuery.getMsgType()),"msg_type",msgDaoQuery.getMsgType());
        queryWrapper.eq(ObjectUtils.isNotEmpty(msgDaoQuery.getHasCancel()),"has_cancel",msgDaoQuery.getHasCancel());
        queryWrapper.eq(ObjectUtils.isNotEmpty(msgDaoQuery.getMsgRecipientId()),"msg_recipient_id",msgDaoQuery.getMsgRecipientId());
        return baseList(queryWrapper);
    }

    @Override
    public List<MsgPo> selectByCurrentUser() {
        return baseMapper.selectByCurrentUser(SessionUtil.getUserId());
    }

}
